package org.example.ttms.customize;

import org.example.ttms.controller.AddTripsController;
import org.example.ttms.entityClass.ticket.Ticket;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class AddTicket extends Window {
    private int businessSeatNum;
    private int firstSeatNum;
    private int secondSeatNum;
    private int allSeatNum;
    private double businessSeatPrice;
    private double firstSeatPrice;
    private double secondSeatPrice;
    public static String tripsId;
//    public static String id;

    public int getBusinessSeatNum() {
        return businessSeatNum;
    }

    public void setBusinessSeatNum(int businessSeatNum) {
        this.businessSeatNum = businessSeatNum;
    }

    public int getFirstSeatNum() {
        return firstSeatNum;
    }

    public void setFirstSeatNum(int firstSeatNum) {
        this.firstSeatNum = firstSeatNum;
    }

    public int getSecondSeatNum() {
        return secondSeatNum;
    }

    public void setSecondSeatNum(int secondSeatNum) {
        this.secondSeatNum = secondSeatNum;
    }

    public int getAllSeatNum() {
        return allSeatNum;
    }

    public void setAllSeatNum(int allSeatNum) {
        this.allSeatNum = allSeatNum;
    }

    public double getBusinessSeatPrice() {
        return businessSeatPrice;
    }

    public void setBusinessSeatPrice(double businessSeatPrice) {
        this.businessSeatPrice = businessSeatPrice;
    }

    public double getFirstSeatPrice() {
        return firstSeatPrice;
    }

    public void setFirstSeatPrice(double firstSeatPrice) {
        this.firstSeatPrice = firstSeatPrice;
    }

    public double getSecondSeatPrice() {
        return secondSeatPrice;
    }

    public void setSecondSeatPrice(double secondSeatPrice) {
        this.secondSeatPrice = secondSeatPrice;
    }

    //添加车票窗口
    public void addTicketWindow(){
        title = "添加车票";
        window("addTicket.fxml");
    }

    //添加车票
    public List<String> addTicket(){
        List<String> list = new ArrayList<>();
        int i = 1;
        Ticket ticket;
        String ticketId;
        Date date = AddTripsController.date;
        for(; i <= businessSeatNum; i++){
            ticketId = date + "-" + tripsId+"-B"+i;
            ticket = new Ticket(tripsId, ticketId, "商务座", businessSeatPrice, date);
            ticket.addTicket(ticket);
            list.add(tripsId+"-B"+i);
        }
        for(; i <= businessSeatNum+firstSeatNum; i++){
            ticketId = date + "-" + tripsId+"-F"+i;
            ticket = new Ticket(tripsId, ticketId, "一等座", firstSeatPrice, date);
            ticket.addTicket(ticket);
            list.add(tripsId+"-F"+i);
        }
        for(; i <= allSeatNum; i++){
            ticketId = date + "-" + tripsId+"-S"+i;
            ticket = new Ticket(tripsId, ticketId, "二等座", secondSeatPrice, date);
            ticket.addTicket(ticket);
            list.add(tripsId+"-S"+i);
        }
        return list;
    }

}
